package me.a_littlesquid.origin.tasks;

import me.a_littlesquid.origin.utils.remove;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitRunnable;

import java.io.File;

import static org.bukkit.potion.PotionEffectType.*;
import static org.bukkit.potion.PotionEffectType.DAMAGE_RESISTANCE;

public class potion extends BukkitRunnable {

    private Player player;
    public potion(Player player){
        this.player=player;
    }
    @Override
    public void run() {
        File filedata=new File(me.a_littlesquid.origin.Origin.getProvidingPlugin(me.a_littlesquid.origin.Origin.class).getDataFolder(),"data.yml");
        FileConfiguration data= YamlConfiguration.loadConfiguration(filedata);
        String playername=player.getDisplayName();
        String origin=data.getString("playerlist."+playername+".origin");
        LivingEntity entity=player;
        remove.removepotion(player,data,filedata);
        switch (origin) {
            case "ck":
                PotionEffect liliang=new PotionEffect(INCREASE_DAMAGE,1728000,3,false,true,true);
                PotionEffect sudu=new PotionEffect(SPEED,1728000,1,false,true,true);
                PotionEffect baohe=new PotionEffect(SATURATION,1728000,5,false,true,true);
                PotionEffect jipo=new PotionEffect(FAST_DIGGING,1728000,2,false,true,true);
                entity.addPotionEffect(liliang);
                entity.addPotionEffect(sudu);
                entity.addPotionEffect(baohe);
                entity.addPotionEffect(jipo);
                break;
            case "zt":
                PotionEffect kangxing=new PotionEffect(DAMAGE_RESISTANCE,1728000,1,false,true,true);
                PotionEffect huanman=new PotionEffect(SLOW,1728000,1,false,true,true);
                PotionEffect jie=new PotionEffect(HUNGER,1728000,1,false,true,true);
                entity.addPotionEffect(kangxing);
                entity.addPotionEffect(huanman);
                entity.addPotionEffect(jie);
                break;
            case "zzgw":
                PotionEffect xvruo=new PotionEffect(WEAKNESS,1728000,1,false,true,true);
                PotionEffect sudu1=new PotionEffect(SPEED,1728000,1,false,true,true);
                entity.addPotionEffect(xvruo);
                entity.addPotionEffect(sudu1);
                break;
            case "xt":
                PotionEffect shengmingghuifu=new PotionEffect(REGENERATION,1728000,2,false,true,true);
                PotionEffect liliang1=new PotionEffect(INCREASE_DAMAGE,1728000,1,false,true,true);
                PotionEffect jipo1=new PotionEffect(FAST_DIGGING,1728000,1,false,true,true);
                PotionEffect sudu2=new PotionEffect(SPEED,1728000,1,false,true,true);
                PotionEffect jie1=new PotionEffect(HUNGER,1728000,1,false,true,true);
                entity.addPotionEffect(shengmingghuifu);
                entity.addPotionEffect(liliang1);
                entity.addPotionEffect(jipo1);
                entity.addPotionEffect(sudu2);
                entity.addPotionEffect(jie1);
                break;
            case "qs":
                PotionEffect sudu3=new PotionEffect(SPEED,1728000,1,false,true,true);
                PotionEffect kangxing2=new PotionEffect(DAMAGE_RESISTANCE,1728000,1,false,true,true);
                PotionEffect liliang2=new PotionEffect(INCREASE_DAMAGE,1728000,1,false,true,true);
                PotionEffect huanjiang=new PotionEffect(SLOW_FALLING,1728000,1,false,true,true);
                entity.addPotionEffect(sudu3);
                entity.addPotionEffect(kangxing2);
                entity.addPotionEffect(liliang2);
                entity.addPotionEffect(huanjiang);
                break;
            case "my":
                PotionEffect sudu4=new PotionEffect(SPEED,1728000,1,false,true,true);
                PotionEffect kangxing3=new PotionEffect(DAMAGE_RESISTANCE,1728000,2,false,true,true);
                entity.addPotionEffect(sudu4);
                entity.addPotionEffect(kangxing3);
                break;
            case "zs":
                PotionEffect kangxing4=new PotionEffect(DAMAGE_RESISTANCE,1728000,1,false,true,true);
                entity.addPotionEffect(kangxing4);
                break;
            case "pt":
                break;
        }
    }
}
